clear all
*cap log close
set more off
set seed 603

* create dataset for monotonicity robustness ----------------------------

* categorize officers -------------------------
use "${data}/out/3-officer", clear
gen hiexp = (exp2>=5)
gen white = (race=="W")
replace female = 0 if mi(female)
replace college = 0 if mi(college)
egen ocell = group(female white college hiexp)
keep officerid ocell 
tempfile cell
save    `cell'

* get FLL passers -----------------------------
use "${est}/fll_sub", clear
ren jid officerid 
keep officerid 
drop if mi(officerid)
duplicates drop 
tempfile temp 
save    `temp'

* compile data sources ----------------------
use "${data}/out/4-main", clear
merge m:1 officerid using `temp', keep(1 3)
gen fll = (_m==3)
drop _m 
merge m:1 officerid using `cell', keep(1 3) nogen

* compute within group IV -----------------
egen W = group(covbin1)
bysort officerid W: egen sumharsh = sum(harsh)
bysort officerid W: egen sumstops = sum(1)
gen Zw = (sumharsh-harsh)/(sumstops-1)

* set up for transfer to R -----------------
gen dcell = covbin1 
gen Y = cite_ny1 
gen D = harsh 
gen jid = officerid 
keep Y D Z Zw jid ocell dcell W fll totfe 
qui compress
save "${temp}/mono_data", replace
* -----------------------------------------------------------------------



 
